﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TreeMaps.Controls;

namespace ZOIL.Library.Components
{
    /// <summary>
    /// Interaction logic for FacetCloud.xaml
    /// </summary>
    public partial class FacetCloud : DockPanel
    {
        #region ItemsTemplate

        /// <summary>
        /// ItemsTemplate Dependency Property
        /// </summary>
        public static readonly DependencyProperty ItemsTemplateProperty =
            DependencyProperty.Register("ItemsTemplate", typeof(DataTemplate), typeof(FacetCloud),
                new FrameworkPropertyMetadata((DataTemplate)new DataTemplate(),
                    FrameworkPropertyMetadataOptions.None));

        /// <summary>
        /// Gets or sets the ItemsTemplate property.  This dependency property 
        /// indicates ....
        /// </summary>
        public DataTemplate ItemsTemplate
        {
            get { return (DataTemplate)GetValue(ItemsTemplateProperty); }
            set { SetValue(ItemsTemplateProperty, value); }
        }

        #endregion

        

        public FacetCloud()
        {
            InitializeComponent();
            //Rectangle rect1 = new Rectangle();
            //rect1.Fill = Brushes.Blue;
            //Rectangle rect2 = new Rectangle();
            //rect2.Fill = Brushes.Red;
            //Rectangle rect3 = new Rectangle();
            //rect3.Fill = Brushes.Yellow;
            //Rectangle rect4 = new Rectangle();
            //rect4.Fill = Brushes.Violet;
            //Rectangle rect5 = new Rectangle();
            //rect5.Fill = Brushes.Green;
            //Rectangle rect6 = new Rectangle();
            //rect6.Fill = Brushes.YellowGreen;

            //TreeMaps.Controls.TreeMapsPanel t = new TreeMapsPanel();
            //TreeMapsPanel t1 = new TreeMapsPanel();

            //TreeMaps.Controls.SquarifiedTreeMapsPanel treemap = new SquarifiedTreeMapsPanel();
            //treemap.Children.Add(rect1);
            //treemap.Children.Add(rect2);
            //treemap.Children.Add(rect3);
            //treemap.Children.Add(rect4);
            //treemap.Children.Add(rect5);
            //treemap.Children.Add(rect6);

            //TreeMapItem temp2 = (TreeMapItem)treemap.Children[0];
            ////temp2.Header = "test";

            //this.Children.Add(treemap);

            TreeMaps.Controls.TreeMaps s = new TreeMaps.Controls.TreeMaps();


            List<GeographicArea> items = new List<GeographicArea>();

            items.Add(new GeographicArea("France", "../Images/Flags/flag_france.png", 1035000));
            items.Add(new GeographicArea("United Kingdom", "../Images/Flags/flag_great_britain.png", 2564000));
            items.Add(new GeographicArea("Italy", "../Images/Flags/flag_italy.png", 695603));
            items.Add(new GeographicArea("USA", "../Images/Flags/flag_usa.png", 5564000));
            items.Add(new GeographicArea("Germany", "../Images/Flags/flag_germany.png", 1565000));
            items.Add(new GeographicArea("Japan", "../Images/Flags/flag_japan.png", 2564000));
            items.Add(new GeographicArea("Canada", "../Images/Flags/flag_canada.png", 1664000));

            s.ItemsSource = items;
            s.TreeMapMode = TreeMapAlgo.Squarified;
            s.ItemTemplate = this.ItemsTemplate;
            this.Children.Add(s);

        }

        public class GeographicArea
        {
            private ImageSource _image;
            private double _sales;
            private string _name;

            public GeographicArea(string name, string imagePath, double sales)
            {
                _name = name;
                _image = new BitmapImage(new Uri(imagePath, UriKind.RelativeOrAbsolute));
                _sales = sales;
            }

            public string Name
            {
                get { return _name; }
                set { _name = value; }
            }

            public double Sales
            {
                get { return _sales; }
                set { _sales = value; }
            }

            public ImageSource Image
            {
                get { return _image; }
                set { _image = value; }
            }

        }

    }
}
